package com.yk.service;

import org.apache.commons.lang.math.RandomUtils;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.UUID;


@EnableBinding(Source.class) // 定义消息的推送管道
public class IMessageProviderImpl implements IMessageProvider {

    @Resource
    private MessageChannel output;//消息发送管道
    @Override
    public String send() {
        String id = UUID.randomUUID().toString();
        System.out.println("发送消息:" + id);
        output.send(MessageBuilder.withPayload(id).build());
        return id;
    }

}
